package com.charge.service.impl;

import com.charge.dao.UserMapping;
import com.charge.domain.User;
import com.charge.service.UserService;
import com.charge.util.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Description :
 * Author : 91658
 * Date : 2018/6/7 11:30
 **/
@Service("/userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapping userMapping;

    @Override
    public User checkUser(User user) {
        user.setPassword(MD5Utils.encodeByMd5(user.getPassword()));
        return userMapping.selectUser(user);
    }

    @Override
    @Transactional
    public User updateUserInfo(User user) {
        int column = userMapping.updateByPrimaryKeySelective(user);
        if (column > 0) {
            return user;
        }
        return null;
    }
}
